package com.rainbow.common.core.constant;

/**
 * 系统共用常量
 * @author 傅为地
 */
public class Constant {

    /**
     * 全局请求token
     */
    public static final String AUTHORIZATION = "authorization";

    /**
     * 全局日志前缀，从网关过来的整个链路请求，打印日志时，需要在最前面打印全局日志前缀，方便业务纠错
     */
    public static final String GLOBAL_LOG_PREFIX = "GLOBAL_LOG_PREFIX";

    /**
     * oauth2存储redis时，默认前缀
     */
    public static final String AUTH_RESOURCE_ID = "oauth2_redis_store_";

    /**
     * 配置全局拦截器配置项
     */
    public static final String RAINBOW_COMMON_AUTH_PREFIX = "rainbow.common.handler.auth";

    /**
     * oauth认证配置项
     */
    public static final String AUTHORITY_PREFIX = "ROLE_";

    /**
     * oauth认证配置项
     */
    public static final String AUTHORITY_CLAIM_NAME = "authorities";

    /**
     * 后台管理接口路径匹配,oauth认证配置项
     */
    public static final String ADMIN_URL_PATTERN = "*_/youlai-admin/**";

    /**
     * 认证信息Http请求头,oauth认证配置项
     */
    public static final String JWT_TOKEN_HEADER = AUTHORIZATION;

    /**
     * Redis缓存权限规则key,存储全部系统role_menu权限数据,oauth认证配置项
     */
    public static final String PERMISSION_ROLES_ALL_KEY = "AUTH:RESOURCE_ROLES_MAP";

    /**
     * 编辑角色权限时,受影响的用户hash前缀
     */
    public static final String PERMISSION_REF_USER_KEY = "AUTH:PERMISSION_REF_USER_KEY";

    /**
     * 请求头用户名
     */
    public static final String USER_NAME = "username";

    /**
     * 请求头用户名
     */
    public static final String USER_PRINCIPAL = "authuser";

    /**
     * 微服务请求网关的url地址参数key
     */
    public static final String USER_TOKEN_PERMISSION = "tokenUrl";

    /**
     * 微服务请求网关客户端编号
     */
    public static final String USER_TOKEN_CLIENT_ID = "clientId";

    /**
     * 微服务请求国际化参数
     */
    public static final String REQUEST_ACCEPT_LANGUAGE = "Accept-Language";

    /**
     * resetTempalte请求时，携带的版本号
     */
    public static final String SERVICE_VERSION = "version";

    /**
     * nacos服务集群配置key
     */
    public static final String SERVICE_CLUSTER = "nacos.cluster";


    /**
     * 微服务内部调用认证服务名称
     */
    public static final String INNER_AUTH_VERIFY_NAME = "auth";

    /**
     * 微服务内部调用认证url地址，不走nexpion
     */
    public static final String INNER_AUTH_VERIFY_URL = "/oauth/hasRights";

    /**
     * auth服务验证个人信息
     */
    public static final String LOGIN_SUCCESS = "登录成功!";

    public static final String USERNAME_PASSWORD_ERROR = "用户名或密码错误!";

    public static final String USER_PHONE_ERROR = "用户手机号错误!";

    public static final String CREDENTIALS_EXPIRED = "该账户的登录凭证已过期，请重新登录!";

    public static final String ACCOUNT_DISABLED = "该账户已被禁用，请联系管理员!";

    public static final String ACCOUNT_LOCKED = "该账号已被锁定，请联系管理员!";

    public static final String ACCOUNT_EXPIRED = "该账号已过期，请联系管理员!";

    public static final String PERMISSION_DENIED = "没有访问权限，请联系管理员!";

    /**
     * 国际化i18n对应的threadlocal的key
     */
    public static final String GLOBAL_MESSAGE_I18N_KEY = "global_message_key";

    /**
     * 系统登录用户
     */
    public static final String CURRENT_LOGIN_USER = "currentUserId";

    /**
     * 系统登录用户
     */
    public static final String CURRENT_LOGIN_SMS_CODE = "code";


    /**
     * 系统登录用户编号
     */
    public static final String CURRENT_LOGIN_USER_ID = "id";

    /**
     * 系统登录用户名称
     */
    public static final String CURRENT_LOGIN_USER_NAME = "username";

    /**
     * 系统登录用户昵称
     */
    public static final String CURRENT_LOGIN_USER_NICK_NAME = "nickname";

    /**
     * 系统登录用户手机号
     */
    public static final String CURRENT_LOGIN_USER_PHONE = "phone";

    /**
     * 系统登录用户手机号
     */
    public static final String CURRENT_LOGIN_USER_EMAIL = "email";

    /**
     * 系统默认账户名称
     */
    public static final String SYSTEM_DEFAULT_USER_NAME = "rainbow";


    /**
     * 全局日志异常类型
     */
    public static final String GLOBAL_LOG_ABNORMAL_TYPE = "0";

    /**
     * 全局日志正常类型
     */
    public static final String GLOBAL_LOG_NORMAL_TYPE = "1";

    /**
     * nexpion的header令牌key
     */
    public static final String NEXPION_HEADER_TOKEN = AUTHORIZATION;


    /**
     * xxlJob登录生成的cookie的key
     */
    public static final String XXL_JOB_LOGIN_COOKIE_KEY = "set-cookie";


    /**
     * xxlJob登录生成的cookie存储redis时key
     */
    public static final String XXL_JOB_COOKIE_REDIS_KEY = "xxljob-redis-cookie";

    /**
     * xxlJob登录生成的cookie过期时间,默认2小时(单位小时)
     */
    public static final Integer XXL_JOB_COOKIE_REDIS_TIMEOUT = 2;


    /**
     * xxlJob登录生成的cookie的value前缀
     */
    public static final String XXL_JOB_LOGIN_COOKIE_IDENTITY = "XXL_JOB_LOGIN_IDENTITY";


    /**
     * mq半事务生产者处理,业务类型key
     */
    public static final String MQ_PRODUCER_BUSINESS_TYPE = "business_type";

    /**
     * mq消息的主题
     */
    public static final String MQ_TOPIC = "topic";

    /**
     * mq消息的标签
     */
    public static final String MQ_TAG = "tag";

    /**
     * mq消息体全局事务id
     */
    public static final String MQ_MSG_GLOBAL_ID = "globalId";

    /**
     * mq消息体分支事务id
     */
    public static final String MQ_MSG_BRANCH_ID = "branchId";


    /**
     * 登录认证的key
     */
    public interface AuthLoginKey {
        String grantType = "grant_type";
        String username = "username";
        String password = "password";
        String clientId = "client_id";
        String clientSecret = "client_secret";
    }

}
